#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from envelopes import Envelope
# 发送人个人信息
user = 'songcwzjut@163.com'
password = '*******'

# 群发邮件，{姓名:邮箱} 字典
email_dict= {'张航': '279002915@qq.com', '陈颖':'240107654@qq.com'}

for name, email in email_dict.items():
    # 正文
    body = """
亲爱的%s同学:
为了久藏你的影子,在深冬,我给心灵再上一把锁。而如今,在这个日子,我从锁眼里仿佛
""" % name

    # 信封对象
    envelope = Envelope(
        from_addr=(user, 'From William Song'),
        to_addr=(email, 'To you'),
        subject='给你一个问候' + name,
        text_body=body)
    # 附件
    envelope.add_attachment('000930.xlsx')

    # 发送
    envelope.send('smtp.163.com', login=user, 
        password=password, tls=True)

